﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.ExportToVis.CApExportToVisApp
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using System.Diagnostics;
using System.Windows.Forms;
using Tecnomatix.Engineering;


namespace DnProcessSimulateCommands.ExportToVis;

public class CApExportToVisApp
{
  private CApExportToVisManager m_manager;
  private CApExportToVisViewModel _apVM;
  private string m_filename;
  private string JTFileExtension = ".jt";

  public CApExportToVisApp(CApExportToVisViewModel _apVM)
  {
    this.m_filename = _apVM.m_filename;
    this._apVM = _apVM;
  }

  public bool Launch()
  {
    Cursor current = Cursor.Current;
    Cursor.Current = Cursors.WaitCursor;
    this.ExportMonolithicJT();
    this.m_manager = new CApExportToVisManager(this._apVM);
    this.m_manager.GenerateRoot();
    new CApExportToVisPLMXMLWriter(this.m_filename, this._apVM)
    {
      m_animationFramesFileName = this.m_manager.m_AnimationFramesFileName
    }.CreateFile();
    TxApplication.RefreshDisplay();
    Process.Start(this._apVM.Output);
    Cursor.Current = current;
    return true;
  }

  private void ExportMonolithicJT()
  {
    if (CApExportToVisUtilities.IsGraphicViewerEmpty())
    {
      int num = (int) MessageBox.Show(CApExportToVisUtilities.GetResourceManager().GetString("ERROR_EMPTY_GRAPHIC_VIEWER"), CApExportToVisUtilities.GetResourceManager().GetString("CMD_NAME"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
    }
    else
      new CApExportToVisJTCreator($"{this._apVM.Output}\\{this.m_filename}{this.JTFileExtension}").CreateJTFile();
  }
}
